#include "circle.h"

void circle::Draw(HWND hwnd,int xt, int yt)
{
	if(xt<100)
		xt=100;
	else if(xt>700)
		xt=700;
	if(yt>600)
		yt=600;
	SetBr((xt - m_pos.GetX())/2);
	SetSr((xt - m_pos.GetX())/2);

	HDC hdc = GetDC(hwnd);
	
		Ellipse(hdc,m_pos.GetX(),m_pos.GetY(),m_pos.GetX() + m_br*2,m_pos.GetY() + m_sr*2);

	ReleaseDC (hwnd, hdc) ;
}

void circle::Draw(HWND hwnd)
{

	HDC hdc = GetDC(hwnd);
	
		Ellipse(hdc,m_pos.GetX(),m_pos.GetY(),m_pos.GetX() + m_br*2,m_pos.GetY() + m_sr*2);

	ReleaseDC (hwnd, hdc) ;
}

void circle::Hide(HWND hwnd)
{

	HDC hdc = GetDC(hwnd);

		HPEN hPen = CreatePen (PS_SOLID,1,RGB(255,255,255));
		SelectObject (hdc, hPen);
		Ellipse(hdc,m_pos.GetX(),m_pos.GetY(),m_pos.GetX() + m_br*2,m_pos.GetY() + m_sr*2);
		//DeleteObject(hpen);

	ReleaseDC (hwnd, hdc) ;
}

bool circle::operator==(const circle &right) const
{
	if(!(m_pos == right.m_pos))
		return false;
	if(m_br != right.GetBr() || m_sr != right.GetSr())
		return false;

	return true;
}

const circle& circle::operator =(const circle &right)
{
	if(this != &right)
	{
		m_pos = right.m_pos;
		SetBr(right.GetBr());
		SetSr(right.GetSr());
	}

	return *this;
}

ostream& operator<<(ostream &output,circle c)
{
	output << "pos = " << c.m_pos << "," << "r = " <<c.m_br << endl;

	return output;
}

